﻿<%@  Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<PersonalAlbumModel>"%>
<%@ Import Namespace ="MyAlbum.Model" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<span class="ajaxLoader" id="ajaxLoaderSupport" style="display:none"><%=Model.Localize("SendToFriend.working")%></span>
<%using (Html.BeginForm("AddSupport", "Support", FormMethod.Post, new { id = "addSupportForm" }))
  { %>
<fieldset>
<%--Html. AntiForgeryToken() --%>
    <table>
        <tr>
            <td>
                <span class="supportTitle">
                <label for="Support_Name">
                <%=Model.Localize("Support.Name")%> *:
                </label>
                </span>
            </td>
            <td>
                <%=Html.TextBox("Support.Name", null, new { maxlength = "80" })%>
            </td>
        </tr>
        <tr>
            <td>
                <span class="supportTitle">
                <label for="Support_Subject">
                <%=Model.Localize("Support.Subject")%> * :
                </label>
                </span>
            </td>
            <td>
                <%=Html.TextBox("Support.Subject", null, new { maxlength = "100" })%>
            </td>
        </tr>
        <tr>
            <td>
                <span class="supportTitle">
                <label for="Support_Email">
                <%=Model.Localize("Support.Email")%> *:
                </label>
                </span>
            </td>
            <td>
                <%=Html.TextBox("Support.Email", null, new { maxlength = "100" })%>
            </td>
        </tr>
        <tr>
            <td>
                  <span class="supportTitle">
                <label for="Support_Body">
                <%=Model.Localize("Support.Body")%> :
                </label>
                </span>
            </td>
            <td>
                <%=Html.TextArea("Support.Body")%>
            </td>
        </tr>
        <tr>
            <td colspan="2">    
                <input type="button" id="btnSubmitSupport" onclick="javascript:doSupport()" class="submitButton" value="<%=Model.Localize("Support.Submit")%>" />
            </td>
        </tr>
    </table>
</fieldset>

<%}%>
<script type="text/javascript">
<!--
    function doSupport() {
        document.getElementById('btnSubmitSupport').disabled = true;
        $('ajaxLoaderSupport').show();
        var form = document.getElementById('addSupportForm');
        $.ajax({
            url: form.action,
            type: form.method,
            dataType: 'json',
            data:$(form).serialize(),
            complete: $('ajaxLoaderSupport').hide(),
            success: function(j) {
                if (j.error) {
                    document.getElementById('btnSubmitSupport').disabled = false;
                    if (j.message) {
                        alert(j.message);
                    } else {
                        alert('<%=Model.Localize("Entry.Error") %>');
                    }
                } else {
                    alert('<%=Model.Localize("Suport.supportSubmited") %>');
                    form.reset();
                }
            }, error: function(err) {
                document.getElementById('btnSubmitSupport').disabled = false;
                alert('<%=Model.Localize("Entry.Error") %>');
            }
        });
    }
    -->
</script>
  <%if (Model.User.AllowActions())
  {%>
  <p>Current Requests:</p>
      <table cellpadding="0" cellspacing="0">
        <tr>
            <th>
                <%=Model.Localize("Support.Id")%>
            </th>
            <th>
               <%=Model.Localize("Support.Date")%>
            </th>
            <th>
                  <%=Model.Localize("Support.Name")%>
            </th>
            <th>
                  <%=Model.Localize("Support.Email")%>
            </th>
            <th>
                  <%=Model.Localize("Support.Subject")%>
            </th>
            <th>
                  <%=Model.Localize("Support.Body")%>
            </th>
            <th>
                 <%=Model.Localize("Support.Answered")%>
            </th>
            <th>&nbsp;</th>
            <th>&nbsp;</th>
        </tr>
     <% foreach (var item in ViewData.Model.SupportRequests)
      {%>
          <tr <%=item.IsActive?"style=\"background-color:red\"":null %>>
            <td>
                <%=item.Id %>
            </td>
            <td>
            &nbsp; <%=item.TimeStamp %>
            </td>
            <td>
               &nbsp; <%=Html.Encode(item.Name) %>
            </td>
            <td>
            &nbsp;<%=Html.Encode(item.Email) %>
            </td>
            <td>
               &nbsp; <%=Html.Encode(item.Subject) %>
            </td>
            <td>
               &nbsp; <%=Html.Encode(item.Body) %>
            </td>
            <td>
                &nbsp;<%=item.IsActive?"No":"Yes" %>
            </td>
            <td>
               <%-- &nbsp;<%=item.IsActive?Html.ActionLink<SupportController>(c=>c.Update(item.Id),Model.Localize("Support.MarkAnswered")):null %>--%>
               <%if (item.IsActive)
                 { %>
               <%using (Html.BeginForm<SupportController>(a => a.Update(item.Id)))
                 { %>
                 <%--Html. AntiForgeryToken() --%>
                &nbsp;<input type="submit" value="<%=Model.Localize("Support.MarkAnswered") %>" />
                <%}
                 }%>
            </td>
            <td>
               <%-- &nbsp;<%=Html.ActionLink<SupportController>(c=>c.Delete(item.Id), Model.Localize("Support.Delete"))%>--%>
               <%using (Html.BeginForm<SupportController>(a => a.Delete(item.Id)))
                 { %>
                 <%--Html. AntiForgeryToken() --%>
                 &nbsp;<input type="submit" value="<%=Model.Localize("Support.Delete") %>" />
                 <%} %>
            </td>
          </tr>
          

      <%
      }%>
      </table>
  <%} %>
</asp:Content>
